package fy.mdm.operator;

import com.seeyon.v3x.services.flow.bean.FlowExport;

import fy.form.listen.operate.AForm_Save_Operator;
import fy.form.listen.operate.IFormOperator;
import fy.mdm.bean.SampleReviewBean;
import fy.mdm.dao.SampleReviewDao;

public class SampleReviewFormOperator extends AForm_Save_Operator implements IFormOperator {
	private SampleReviewBean bean = new SampleReviewBean();
	@Override
	protected void parseOtherField_FirstStep(FlowExport flowExport) {
		bean.setSummaryId(super.formBean.getSummaryId());
		bean.setBillname(flowExport.getFlowTitle());
		bean.setApplier(flowExport.getFlowCreatePerson().getName());
		bean.setTs(flowExport.getFlowCreateTime());
	}

	@Override
	protected void parseValueExport(com.seeyon.v3x.services.form.bean.ValueExport ve) {
		String fieldName = ve.getDisplayName();
		if ("产品编码".equals(fieldName)) {
			bean.setMaterialCode(ve.getValue());
		} else if ("产品名称".equals(fieldName)) {
			bean.setMaterialName(ve.getValue());
		} else if ("采购状态".equals(fieldName)) {
			bean.setPurchaseStatus(Integer.valueOf(ve.getValue()));
		} else if ("适用子公司".equals(fieldName)) {
			bean.setSubsidiary(ve.getValue());
		} else if ("MDM物料类别".equals(fieldName)) {
			bean.setFirst_category(ve.getValue());
		} 
	}

	public String getFormName() {
		return "供应商送样评定表";
	}

	public boolean save() {
		try {
			SampleReviewDao sampleReviewDao = new SampleReviewDao();
			sampleReviewDao.setSampleReviewBean(bean);
			return sampleReviewDao.StateReturn();
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			//bean.clear();
				bean = null;
			}
		return success;
	}

}
